/*
 * @Date: 2025-07-14 13:46:29
 * @LastEditors: Csir 2215995096@qq.com
 * @LastEditTime: 2025-07-17 11:37:04
 * @FilePath: \infomng-ui\src\const\crud\pfoc\realityproductlinemain.js
 */
export const tableOption = {
  labelPosition: "left",
  labelSuffix: "：",
  labelWidth: 120,
  gutter: 0,
  menuBtn: true,
  align: "center",
  submitBtn: true,
  submitText: "提交",
  stripe: true,
  emptyBtn: true,
  emptyText: "清空",
  menuPosition: "center",
  border: true,
  index: true,
  indexLabel: "序号",
  addBtn: false,
  editBtn: false,
  delBtn: false,
  searchMenuSpan: 8,
  menuWidth: 240,
  searchEnter: true,
  column: [
    {
      type: "input",
      label: "产线名称",
      prop: "realityLineName",
      span: 12,
      search: true,
      searchLabelWidth: 100,
    },
    {
      type: "select",
      label: "车间名称",
      prop: "workshopId",
      span: 12,
      dicUrl: "/admin-api/o3-pfoc/workshop/getWorkshopList",
      dicMethod: "get",
      props: {
        label: "workshopName",
        value: "id",
      },
      // search: true,
      /*searchslot:true,
      searchLabelWidth:100,*/
    },
    {
      type: "select",
      label: "产线类型",
      prop: "lineType",
      span: 12,
      dicData: [
        //产线类型列表
        {
          value: "手动线",
          label: "手动线",
        },
        {
          value: "自动线",
          label: "自动线",
        },
      ],
      search: true,
      searchLabelWidth: 100,
    },
    {
      type: "input",
      label: "可生产品号",
      prop: "bindArticleNumber",
      span: 12,
    },
    {
      type: "input",
      label: "产线模板名称",
      prop: "lineTplName",
      span: 12,
    },
    /* {
      type: "input",
      label: "工序",
      prop: "processNodes",
      span: 12,
      overHidden: true,
      formatter:(row, value,column) => {
        var html="";
        const json = JSON.parse(value);
        for (var i=0;i<json.length;i++){
          html = html+json[i].name+";";
        }
        return html;
      }
    },
    {
      type: "input",
      label: "工序顺序",
      prop: "processNodeLine",
      span: 12,
      overHidden: true,
      formatter:(row, value,column) => {
        var html="";
        let  json = JSON.parse(value);
        const len = json.length
        for (let i = 0; i < len; i++) {
          for (let j = i+1; j < len; j++) {
            if ( json[i].from ==json[j].to ) {
              const temp = json[j]
              json[j] = json[i]
              json[i] = temp
            }
            if(json[i].to ==json[j].to){
              const temp = json[j]
              json[j] = json[i]
              json[i] = temp
            }
          }
        }

        let newArr =[];
        for(var i =0;i<json.length;i++){
          newArr.push(json[i].from)
          if(i==json.length-1) {
            newArr.push(json[i].to)
          }
        }
        let nameStr ="";
        const json2 = JSON.parse(row.processNodes);
        for(var n =0;n<newArr.length;n++){
          for (var m=0;m<json2.length;m++){
            if(newArr[n]==json2[m].id) {
              nameStr = nameStr + json2[m].name + ";";
            }
          }
        }

        return nameStr;
      }
    },*/
    /*{
      type:"select",
      label: "产线状态",
      prop: "lineStatus",
      span: 12,
      display: false,
      hide:false,
      dicUrl: '/admin-api/system/dict-data/type?type=line_status',
      props: {
        label: "label",
        value: "value"
      },
      dicMethod: "get",
      html:true,//配置html设置为true即可支持formatter转义html代码
      formatter:(val) => {
        if( val.lineStatus=='未生产') {
          return '<b style="color:red">未生产</b>'
        }else if(val.lineStatus=='生产中'){
          return '<b style="color:green">生产中</b>'
        }else if(val.lineStatus=='暂停中'){
          return '<b style="color:orange">暂停中</b>'
        }
      },
    },*/
    {
      prop: "createBy",
      span: 12,
      type: "input",
      label: "发布人",
      dicUrl: "/admin/user/getAllUser",
      props: {
        label: "name",
        value: "username",
      },
      dicMethod: "get",
      display: false,
      hide: false,
    },
    {
      prop: "createTime",
      span: 12,
      type: "datetime",
      label: "发布时间",
      format: "yyyy-MM-dd HH:mm:ss",
      display: false,
      hide: false,
      valueFormat: "yyyy-MM-dd HH:mm:ss",
    },
  ],
};
